package com.mercury.controller;

import com.mercury.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author ：tx
 * @description：
 * @date ：Created in 2019/2/22 15:26
 * @modified By：
 * @version:
 */
@Controller
@RequestMapping("/thymeleaf")
public class ThymeleafController {


    @RequestMapping("/showIndex")
    public String showIndex(Model model){
        model.addAttribute(new User("mercury","11"));
        return "showIndexView";
    }

    @RequestMapping("/register")
    public String register(@Validated  User user, Errors errors){
        if(errors.hasErrors()){
            return "showIndexView";
        }
        return "success";
    }
}
